package de.fhb.itunes.manager.mail.Template;

import java.util.ArrayList;

public class TemplateBuilder {
	private ArrayList<String> filme,musik;
	private ArrayList<Template> templates;

	public TemplateBuilder(ArrayList<String> filme, ArrayList<String> musik) {
		this.filme = filme;
		this.musik = musik;
		templates = new ArrayList<Template>();

	}
	
	public void generateTemplates(String text, String bild_url){
	for (String film : filme) {
		if (text == "")
			text = "Neuer Film";
		templates.add(new Template(random(), text, film, bild_url));
	}
	for (String musik:this.musik){
		if (text == "")
			text = "Neuer Musiktitel";
		templates.add(new Template(random(), text, musik, bild_url));
	}
	
	}
	public ArrayList<Template> getTemplates() {
		generateTemplates("", "");
		return templates;
	}
	private HTML_Templates random() {
		HTML_Templates ret = null;
		int zahl;
		double i;
		do {

			i = Math.random();
			zahl = (int) (i * 10);
		} while (zahl < 1 || zahl > 3);
		switch (zahl) {
		case 1:
			ret = HTML_Templates.fullwidthImage;
			break;
		case 2:
			ret = HTML_Templates.textWithLeftAlignedImage;
			break;
		case 3:
			ret = HTML_Templates.textWithRightAlignedImage;
			break;
		}
		return ret;
	}
}
